/**
 * $Id: BeanUtil.java,v 1.0 2022/6/5 22:41 shidesheng Exp $
 * <p>
 * Copyright 2021 Sinosoft Co.,Ltd. All rights reserved.
 */
package sds.mode.prototype.demo;

import javax.imageio.stream.FileImageInputStream;
import java.lang.reflect.Field;

/**
 * @author shidesheng
 * @version $Id: BeanUtil.java,v 1.1 2022/6/5 22:41 shidesheng Exp $
 * Created on 2022/6/5 22:41
 */
public class BeanUtils {

	public static Object copy(Object prototype){
		Class clazz = prototype.getClass();
		Object returnValue = null;
		try {
			returnValue = clazz.newInstance();
			for (Field field : clazz.getDeclaredFields()){
				field.setAccessible(true);
				// 对属性依次赋值
				field.set(returnValue,field.get(prototype));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;
	}

}
